import { BorrowingDao } from './../dao/borrowingDao'
import { IamInfo } from '../controller/iamInfo'
import { Borrowing } from '../model/borrowing'
import { ResponseList } from '../model/responseList'
export class BorrowingService {
  private readonly borrowingDao = new BorrowingDao()
  queryArrearsList(params: any): Promise<ResponseList<Borrowing>> {
    params.creator = IamInfo.id
    return this.borrowingDao.queryArrearsList(params).then(modelData=>{
      return this.borrowingDao.count(params).then(count => {
        const responseList = new ResponseList<Borrowing>();
        responseList.list=modelData
        responseList.count = count
        return responseList
      })
    })
  }
  upsertArrears(params: any): Promise<any> {
    params.creator = IamInfo.id
    params.updater = IamInfo.id
    return this.borrowingDao.upsertArrears(params)
  }
  deleteArrears(params: any): Promise<number> {
    return this.borrowingDao.deleteArrears(params)
  }
}